<!DOCTYPE html>
<html lang="en">

<head>
    <#include "/lx/admin/components/meta.html" />
    <title>中介公司管理 ${metaTitleSuffix!}</title>
    <#include "/lx/admin/components/stylesheets.html" />
</head>

<body>
    <div id="app">
        <el-container>
            <#assign menuIndex="7-1" />
            <#include "/lx/admin/components/menu.html" />
            <el-container>
                <#include "/lx/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-row>
                            <el-col :span="12">
                                <div class="title theme-color1">中介公司管理</div>
                            </el-col>
                            <el-col :span="12">
                                <div class="operations">
                                    <el-upload class="upload-batch" action="/lx/admin/api/uploadExcel" name="file" :data="{ type: 3 }" :on-success="uploadExcelSuccess" :on-error="uploadExcelError" :on-progress="uploadExcelProgress" accept=".xls,.xlsx" :show-file-list="false">
                                        <el-button type="success" size="small"><i class="el-icon-upload2"></i>批量新增</el-button>
                                    </el-upload>
                                    <el-button type="success" size="small" @click="add"><i class="el-icon-plus"></i>添加</el-button>
                                </div>
                            </el-col>
                        </el-row>
                        <div class="search">
                            <el-input v-model="keyword" style="width: 220px;" clearable placeholder="请输入关键字"></el-input>
                            <el-button @click="onSearch"><i class="el-icon-search"></i>筛选</el-button>
                        </div>
                        <el-table ref="multipleTable" :data="list" tooltip-effect="dark" :stripe='true' style="width: 100%">
                            <el-table-column prop="name" label="名称" show-overflow-tooltip>
                            </el-table-column>
                            <el-table-column prop="englishName" label="英文名称" show-overflow-tooltip>
                            </el-table-column>
                            <el-table-column prop="status" label="状态" width="80">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.status == 1">正常</span>
                                    <span v-if="scope.row.status == 0">禁用</span>
                                </template>
                            </el-table-column>
                            <el-table-column fixed="right" label="操作" width="150">
                                <template slot-scope="scope">
                                    <el-button @click="edit(scope.row)" type="text" size="small">编辑</el-button>
                                    <el-button @click="del(scope.row)" type="text" size="small" style="color: red;">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include "/lx/admin/components/page.html" />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/lx/admin/components/footer.html" />
    </div>
    <#include "/lx/admin/components/scripts.html" />
    <script>
        var vue = new Vue({
        el: '#app',
        data() {
            return {
                list: [],
                fileList:[],
                keyword: '${keyword!}'
            }
        },
        mounted: function() {
        },
        methods: {
            handleExceed(){

            },
            add() {
                window.location.href = "/lx/admin/company/info";
            },
            edit(item) {
                window.location.href = "/lx/admin/company/info?companyId=" + item.id;
            },
            del(item) {
                var self = this;
                confirm("确认删除？请谨慎操作", "确认", function() {
                    var url = "/lx/admin/company/delete"
                    var param = {
                        id: item.id
                    };
                    var success = () => {
                        window.location.href = "/lx/admin/company/list";
                    }
                    var fail = (response) => {
                        msg(response.msg);
                    }
                    var complete = () => {}
                    axiosRequestPro(url, param, success, fail, complete);
                })
            },
            onSearch() {
                var self = this;
                var keys = [
                    { key: 'keyword', value: self.keyword }
                ]
                goPage(1, keys);
            },
            uploadExcelSuccess(response, file, fileList) {
                endLoading();
                console.log(response);
                if (response.status == 200) {
                    remind("批量导入成功", function(index) {
                        window.location.reload();
                        layer.close(index);
                    });
                } else {
                    remind("批量导入失败" + (response.info ? "：" + response.info : ""));
                }
            },
            uploadExcelError(err, file, fileList) {
                endLoading();
                console.log(err);
                remind("上传失败")
            },
            uploadExcelProgress(event, file, fileList) {
                loading();
            },
            onPageChange(val) {
                // console.log('当前页: {val}' + val);
                goPage(val)
            }
        }
    })
    </script>
    <script>
        vue.list = ${items!}
    </script>
    <#include "/lx/admin/components/msg.html" />
    <style type="text/css">
    .title {
        font-size: 18px;
        font-weight: bold;
    }

    .operations {
        display: flex;
        justify-content: flex-end;
    }

    .upload-batch {
        padding-right: 10px;
    }
    </style>
</body>

</html>